<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="js/jquery-2.1.0.js"></script>
		<style type="text/css">
			#iframesub{
				width:0;
				height:0;
			}
		</style>
	</head>
	<body>
		<!--<form action="" enctype='multipart/form-data' method="post" class='subform'>-->
			<input type="file" name="files" id="files" value="" class='inputfiles' />
			<input type="submit" value="提交" class='sub'/>
		<!--</form>-->
		<iframe src="" width="0" height="0" frameborder='0' id='iframesub'></iframe>
		<script type="text/javascript">
			$(function () {
				$('.sub').on('click',function () {
					//var data = $('.subform').serialize();
					var data = new FormData();
					data.append('files',$(".inputfiles")[0].files[0])
					/*$.ajax({
						'url' : '/upload',
						'type' : 'post',
						'data' : data,
						'dataType' : 'json',
						'success' : function (data) {
							console.log(data);
						},
						'error' : function () {
							console.log('error');
						}
					})*/
					
					var data = new FormData();
					data.append('files',$('.inputfiles')[0].files[0]);
					var xhr = new XMLHttpRequest();
					xhr.onreadystatechange = function () {
						if (xhr.status == 200 && xhr.readyState == 4) {
							console.log(xhr.responseText);
						}
					}
					
					xhr.open('post','/upload',true);
					xhr.send(data);
					
					return false;
				});
			});
		</script>
	</body>
</html>
